home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_363 / wo / wo1.0e.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  39KB  |  1,489 lines

  1. /*
  2.  *
  3.  *    Wo1.0e.c
  4.  *
  5.  *        Aztec C V3.4:
  6.  *        cc (+Irad:inlcude.pre) +C +D +L -E140 wo.c
  7.  *        ln wo.o -lml32 -lcl32
  8.  *
  9.  */
  10.  
  11.  
  12. /*
  13.  *    inlcudes and defines
  14.  */
  15.  
  16. /* I compile with pre-compiled include-files !
  17. #include <stdio.h>
  18. #include <ctype.h>
  19. #include <functions.h>
  20. #include <intuition/intuition.h>
  21. #include <intuition/intuitionbase.h>
  22. #include <devices/timer.h>
  23. #include <time.h>
  24. #include <devices/input.h>
  25. #include <libraries/dos.h>
  26. #include <graphics/gfxmacros.h>
  27. */
  28.  
  29. #define ABOUT " Wo 1.0e  © Heinzel 2.3.90 "
  30.  
  31. #define MX  IntuitionBase->ActiveScreen->MouseX
  32. #define MY  IntuitionBase->ActiveScreen->MouseY
  33. #define a_w IntuitionBase->ActiveWindow
  34. #define MAXLEN 255 
  35. #define KEYS sizeof(key)/sizeof(UBYTE)   /* for codiere()/decodiere() */
  36. #define MAXI 500       /* maximal number of records (can be modified, of course) */
  37.  
  38.  
  39. /*
  40.  *    declarations
  41.  */
  42.  
  43. UBYTE key[] = {0,1,2,3,4,5,6,7,8,9,};  /* for password */
  44.  
  45. struct Daten
  46. {
  47.  char such_begriff[32];        
  48.  char name[32];
  49.  char strasse[32];
  50.  char ort[32];
  51.  char tel[32];
  52. };
  53.  
  54. struct Daten *person[MAXI];
  55. int zaehler = 0;   /* for person[zaehler]  */
  56.  
  57. int vergleich();   /* for QuickSort()  */
  58.  
  59. FILE *faus, *fopen();
  60. struct FileHandle *fein;
  61. struct FileLock *lock;
  62. struct FileInfoBlock *eintrag;
  63. char *platz;
  64.  
  65. struct IntuitionBase *IntuitionBase;  
  66. struct GfxBase *GfxBase;
  67. long DosBase=0, j, k;
  68. long i=0;
  69.  
  70. BOOL anderung = FALSE;
  71.     /* has actual file been changed and must be saved ? */
  72.  
  73. struct IntuiMessage *message;
  74. ULONG class; USHORT code;
  75.  
  76. struct MsgPort *timerport = NULL;  /* for timer-clock */
  77. long openerror = 1;
  78. struct timerequest timereq;
  79. ULONG zmem, tt =0;
  80. long diff = 0;
  81.  
  82.  
  83. struct Preferences prefs;   /* for movemouse() */
  84. struct RastPort *rp;
  85. struct Screen *screen;
  86. struct Window *w, *offne_win, *list_win, *input_win, *sesam_win;
  87.  
  88. char liste[MAXI][33];  /* for list() */
  89. char Date_Buffer[10] ;    
  90.  
  91. UBYTE DefString[30];
  92. UBYTE Undo [30];
  93. struct StringInfo TexString =  /* for text in text-gadgets */
  94.  {DefString,Undo,0,30,0,0,0,0, 0,0, NULL, 0, NULL};
  95.  
  96. UBYTE DefString2[30] = ":wo/wo.file";   /* in offne_file-window */
  97. UBYTE Undo2[30];
  98. struct StringInfo TexString2 =
  99.  {DefString2,Undo2,0,30,0,0,0,0, 0,0, NULL, 0, NULL};
  100.  
  101. UBYTE DefString3[30];   /* in input-window */
  102. UBYTE Undo3[30];
  103. struct StringInfo Input_TexString =
  104.  {DefString3,Undo3,0,30,0,0,0,0, 0,0, NULL, 0, NULL};
  105.  
  106. UBYTE DefString4[70];   /*  in sesam-window  */
  107. UBYTE Undo4[70];
  108. struct StringInfo sesam_TexString =
  109.  {DefString4,Undo4,0,70,0,0,0,0, 0,0, NULL, 0, NULL};
  110.  
  111. char alert1[] = {"\0\170\26  W r o n g    P a s s w o r d  ,     S u c k e r  !\0\0"};
  112.  
  113. /*
  114.  *    Borders
  115.  */
  116.  
  117. SHORT Pairs1[] =        /* from Text Gadget Border  */
  118.  {38,36, 250,36, 250,51, 38,51, 38,36 };
  119. SHORT Pairs3[] =        /* ... in offne_file  */
  120.  {21,5, 231,5, 231,21, 21,21, 21,5 };
  121. SHORT Pairs4[] =        /* ... in input_window  */
  122.  {38,16, 250,16, 250,31, 38,31, 38,16 };
  123.  
  124. struct Border StrBorder5 =
  125.  {-17,-11, 1,0,JAM1, 5, Pairs4, NULL };
  126. struct Border StrBorder4 =
  127.  {0,0, 1,0,JAM1, 5, Pairs4, NULL };
  128. struct Border StrBorder3 =
  129.  {0,0, 1,0,JAM1, 5, Pairs3, NULL };
  130. struct Border StrBorder =
  131.  {0,0, 1,0,JAM1, 5, Pairs1, NULL };
  132.  
  133.  
  134. /*
  135.  *    IntuiTexts
  136.  */
  137.  
  138. BOOL ergebnis = FALSE;
  139.  
  140. struct IntuiText postext1 =
  141.  {0,1,JAM2,9,4,NULL,(UBYTE *)"Yo ",NULL };
  142. struct IntuiText negtext1 = 
  143.  {0,1,JAM2,9,4,NULL,(UBYTE *)" NO !",NULL };
  144. struct IntuiText text=
  145.  {0,1,JAM1,9,6,NULL,(UBYTE *)" No reords ! "};  
  146. struct IntuiText text2=
  147.  {0,1,JAM1,9,6,NULL,(UBYTE *)NULL};
  148. struct IntuiText text3=
  149.  {0,1,JAM1,6,6,NULL,(UBYTE *)" No current record !"};
  150. struct IntuiText text4=
  151.  {0,1,JAM1,9,6,NULL,(UBYTE *)" DELETE records ?"};
  152. struct IntuiText text5=
  153.  {0,1,JAM1,9,6,NULL,(UBYTE *)" Save modified file ?"};
  154.  
  155. struct IntuiText yo_str =
  156.  {1,0,JAM2,49,2,NULL,(UBYTE *)"Yo !",NULL };
  157.  
  158. struct IntuiText del_str =
  159.  {3,0,JAM2,1,0,0,(UBYTE *)" Del ",0};
  160. struct IntuiText neu_str =
  161.  {3,0,JAM2,1,0,0,(UBYTE *)" New ",0};
  162. struct IntuiText print_str =
  163.  {3,0,JAM2,1,0,0,(UBYTE *)"  Print  ",0};
  164. struct IntuiText abbruch_str =
  165.  {1,0,JAM1,25,2,0,(UBYTE *)"CANCEL",0};
  166. struct IntuiText list_str =
  167.  {3,0,JAM2,1,0,0,(UBYTE *)"  List ",0};
  168. struct IntuiText input_str =
  169.  {3,0,JAM2,1,0,0,(UBYTE *)" Input ",0};
  170. struct IntuiText speicher_str =
  171.  {3,0,JAM2,1,0,0,(UBYTE *)" Save ",0};
  172. struct IntuiText lade_str =
  173.  {3,0,JAM2,1,0,0,(UBYTE *)" Open ",0};
  174. struct IntuiText edit_str =
  175.  {3,0,JAM2,1,0,0,(UBYTE *)" Edit ",0};
  176.  
  177. struct IntuiText yes_str =
  178.  {1,0,JAM1,14,2,0,NULL,0};
  179. struct IntuiText no_str =
  180.  {1,0,JAM1,25,2,0,(UBYTE *)"Cancel",0};
  181.  
  182.  
  183. struct IntuiText vor_str =
  184.  {1,0,JAM1,4,0,0,(UBYTE *)"--->>>",0};
  185. struct IntuiText zurueck_str =
  186.  {1,0,JAM1,4,0,0,(UBYTE *)"<<<---",0};
  187. struct IntuiText namen_str[13] =
  188. {
  189.  {1,0,JAM2,3,1,0,NULL,0},
  190.  {1,0,JAM2,3,1,0,NULL,0},
  191.  {1,0,JAM2,3,1,0,NULL,0},
  192.  {1,0,JAM2,3,1,0,NULL,0},
  193.  {1,0,JAM2,3,1,0,NULL,0},
  194.  {1,0,JAM2,3,1,0,NULL,0},
  195.  {1,0,JAM2,3,1,0,NULL,0},
  196.  {1,0,JAM2,3,1,0,NULL,0},
  197.  {1,0,JAM2,3,1,0,NULL,0},
  198.  {1,0,JAM2,3,1,0,NULL,0},
  199.  {1,0,JAM2,3,1,0,NULL,0},
  200.  {1,0,JAM2,3,1,0,NULL,0},
  201.  {1,0,JAM2,3,1,0,NULL,0}
  202. };
  203.  
  204. /*
  205.  *    Gadgets
  206.  */
  207.  
  208. struct Gadget yo_gad =
  209.  {NULL, 66,25,120,12, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  210.    NULL,0,&yo_str,0,0, 2, 0}; 
  211. struct Gadget sesam_gad =
  212.  {&yo_gad, 26,9,200,12, GADGHCOMP, RELVERIFY, STRGADGET,
  213.    NULL, 0, NULL, 0, (APTR)&sesam_TexString, 1,0};
  214.  
  215. struct Gadget input_tex_gad =
  216.  {NULL, 45,20,200,12, GADGHCOMP, STRINGCENTER|RELVERIFY, STRGADGET,
  217.    NULL, 0, NULL, 0, (APTR)&Input_TexString, 1,0};
  218.  
  219. struct Gadget zurueck_gad =
  220.  {NULL, 74,170,54,8, GADGHBOX|GADGDISABLED,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  221.    NULL,0,&zurueck_str,0,0, 21, 0}; 
  222. struct Gadget vor_gad =
  223.  {&zurueck_gad, 6,170,54,8, GADGHBOX|GADGDISABLED,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  224.    NULL,0,&vor_str,0,0, 20, 0}; 
  225.  
  226. struct Gadget namen_gad[13] =
  227. {
  228. {&vor_gad,      10, 12,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[0], 0,0,0, 0}, 
  229. {&namen_gad[0], 10, 22,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[1], 0,0,1, 0}, 
  230. {&namen_gad[1], 10, 32,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[2], 0,0,2, 0}, 
  231. {&namen_gad[2], 10, 42,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[3], 0,0,3, 0}, 
  232. {&namen_gad[3], 10, 52,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[4], 0,0,4, 0}, 
  233. {&namen_gad[4], 10, 62,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[5], 0,0,5, 0}, 
  234. {&namen_gad[5], 10, 72,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[6], 0,0,6, 0}, 
  235. {&namen_gad[6], 10, 82,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[7], 0,0,7, 0}, 
  236. {&namen_gad[7], 10, 92,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[8], 0,0,8, 0}, 
  237. {&namen_gad[8], 10,102,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[9], 0,0,9, 0}, 
  238. {&namen_gad[9], 10,112,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[10],0,0,10,0}, 
  239. {&namen_gad[10],10,122,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[11],0,0,11,0}, 
  240. {&namen_gad[11],10,132,110,10, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,NULL,0,&namen_str[12],0,0,12,0}
  241. };
  242.  
  243.  
  244. struct Gadget no_gad =        /* in offne_file-window */
  245.  {NULL, 20,27,100,12, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  246.    NULL,0,&no_str,0,0, 3, 0}; 
  247. struct Gadget yes_gad =
  248.  {&no_gad, 140,27,100,12, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  249.    NULL,0,&yes_str,0,0, 2, 0}; 
  250. struct Gadget file_gad =
  251.  {&yes_gad, 26,9,200,12, GADGHCOMP, STRINGCENTER|RELVERIFY, STRGADGET,
  252.    NULL, 0, NULL, 0, (APTR)&TexString2, 1,0};
  253.  
  254. struct Gadget del_gad =
  255.  {NULL, 119,140,42,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  256.    NULL,0,&del_str,0,0, 10, 0}; 
  257. struct Gadget neu_gad =
  258.  {&del_gad, 161,140,42,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  259.    NULL,0,&neu_str,0,0, 9, 0}; 
  260. struct Gadget edit_gad =
  261.  {&neu_gad, 127,126,50,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  262.    NULL,0,&edit_str,0,0, 8, 0}; 
  263. struct Gadget lade_gad =
  264.  {&edit_gad, 177,126,50,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  265.    NULL,0,&lade_str,0,0, 7, 0}; 
  266. struct Gadget speicher_gad =
  267.  {&lade_gad, 227,126,50,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  268.    NULL,0,&speicher_str,0,0, 6, 0}; 
  269. struct Gadget input_gad =
  270.  {&speicher_gad, 69,126,58,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  271.    NULL,0,&input_str,0,0, 5, 0}; 
  272. struct Gadget list_gad =
  273.  {&input_gad, 11,126,58,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  274.    NULL,0,&list_str,0,0, 4, 0}; 
  275. struct Gadget abbruch_gad =
  276.  {&list_gad, 12,140,99,12, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  277.    NULL,0,&abbruch_str,0,0, 3, 0}; 
  278. struct Gadget print_gad =
  279.  {&abbruch_gad, 203,140,74,8, GADGHBOX,GADGIMMEDIATE|RELVERIFY, BOOLGADGET,
  280.    NULL,0,&print_str,0,0, 2, 0}; 
  281. struct Gadget tex_gad =
  282.  {&print_gad, 45,40,200,12, GADGHCOMP, STRINGCENTER|RELVERIFY, STRGADGET,
  283.    NULL, 0, NULL, 0, (APTR)&TexString, 1,0};
  284.  
  285. struct Requester request =    /* look at function schein-request() */
  286. {NULL,-1,-1,1,1,0,0,NULL,NULL,NULL,NULL,0,NULL,NULL,NULL,NULL,NULL};
  287.  
  288.  
  289. /*
  290.  *    Windows
  291.  */
  292.  
  293. struct NewWindow nw =
  294.   {
  295.    40,20,291,176, 0,1,
  296.    MOUSEBUTTONS|GADGETDOWN|GADGETUP|RAWKEY|CLOSEWINDOW,
  297.    ACTIVATE|RMBTRAP|GIMMEZEROZERO|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE,
  298.    &tex_gad,
  299.    NULL,
  300.    (UBYTE *) ABOUT,
  301.    NULL,
  302.    NULL,
  303.    0,0,0,0, 
  304.    WBENCHSCREEN 
  305.   };
  306.  
  307. struct NewWindow nw3 =        /* name-window  */
  308.   {
  309.    345,20,260,55, 0,1,
  310.    GADGETDOWN|GADGETUP,
  311.    ACTIVATE|RMBTRAP|GIMMEZEROZERO|WINDOWDRAG|WINDOWDEPTH,
  312.    &file_gad,
  313.    NULL,
  314.    NULL,
  315.    NULL,
  316.    NULL,
  317.    0,0,0,0, 
  318.    WBENCHSCREEN 
  319.   };
  320.  
  321. struct NewWindow nw4 =        /* list-window */
  322.   {
  323.    345,5,145,194, 0,1,
  324.    GADGETDOWN|GADGETUP|CLOSEWINDOW|MOUSEBUTTONS,
  325.    ACTIVATE|RMBTRAP|GIMMEZEROZERO|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE,
  326.    &namen_gad[12],
  327.    NULL,
  328.    (UBYTE *) " List  ",
  329.    NULL,
  330.    NULL,
  331.    0,0,0,0, 
  332.    WBENCHSCREEN 
  333.   };
  334.  
  335. struct NewWindow nw5 =        /* input-window */
  336.   {
  337.    345,20,291,50, 0,1,
  338.    GADGETDOWN|GADGETUP|CLOSEWINDOW,
  339.    ACTIVATE|RMBTRAP|GIMMEZEROZERO|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE,
  340.    &input_tex_gad,  /*  Gad */
  341.    NULL,
  342.    NULL,
  343.    NULL,
  344.    NULL,
  345.    0,0,0,0, 
  346.    WBENCHSCREEN 
  347.   };
  348.  
  349. struct NewWindow nw6 =        /* sesam-window */
  350.   {
  351.    345,80,260,55, 0,1,
  352.    GADGETUP|GADGETDOWN,
  353.    ACTIVATE|RMBTRAP|GIMMEZEROZERO|WINDOWDRAG|WINDOWDEPTH,
  354.    &sesam_gad,
  355.    NULL,
  356.    (UBYTE *) " password: ",
  357.    NULL,
  358.    NULL,
  359.    0,0,0,0, 
  360.    WBENCHSCREEN 
  361.   };
  362.  
  363. struct NewWindow new_inf_win =        /* info_window */
  364.  {0,90,640,28, 1,2, NULL, ACTIVATE,
  365.    NULL,NULL,NULL, NULL,
  366.    NULL, 20,20,640,256, WBENCHSCREEN
  367.  };
  368.  
  369.  
  370. /*
  371.  *    master control program
  372.  */
  373.  
  374. main(argc,argv)
  375. short argc;
  376. char *argv[];
  377. {
  378. if( IntuitionBase->ActiveScreen->Width<639 ) ende(7);
  379.  
  380. if(!(DosBase=(long)OpenLibrary("dos.library",0))) ende(1);
  381. if(!(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0))) ende(2);
  382. if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0))) ende(3);
  383.  
  384. GetPrefs(&prefs,(long)sizeof(struct Preferences));
  385.  
  386. if(!(timerport = CreatePort("Timer Port",0L))) ende(4);
  387. if((openerror = OpenDevice(TIMERNAME,UNIT_VBLANK,(char *)&timereq,0L))!=0) ende(4);
  388.  
  389. if(argc>1)  strcpy(DefString2,argv[1]); 
  390.  
  391. draw();
  392.  
  393. start_timer();
  394.  zmem = time(tt)-diff;
  395. print_time(diff);
  396.  
  397. for(i=0;i<MAXI;i++) person[i] = 0;
  398.  
  399. offne_file(0);
  400. s();
  401.  
  402. loop();   /* THE main-loop */
  403. }  /*  End main()  */
  404.  
  405. loop()
  406. {
  407.   for(;;)
  408.    {
  409.     Wait((1<<w->UserPort->mp_SigBit) | (1<<timerport->mp_SigBit));
  410.  
  411.      while(message = (struct IntuiMessage *)GetMsg(w->UserPort))
  412.      {
  413.       class = message->Class;
  414.       code = message->Code;
  415.       ReplyMsg(message);
  416.       switch (class)
  417.        {
  418.     case CLOSEWINDOW:  ende(0);
  419.     case GADGETUP:     do_gadget_text(message, w);  break;
  420.         case GADGETDOWN:   do_gadgets_bool(message, w); break;    
  421.     case RAWKEY:       if(code==80) ActivateGadget(&tex_gad,w,NULL); break;
  422.        }   /*  End switch  */
  423.      }     /*  End while1  */
  424.  
  425.      while(GetMsg(timerport))
  426.       {start_timer();
  427.        diff=time(tt)-zmem;
  428.        print_time(diff);
  429.       }  /* end while2 */
  430.  
  431.    }  /*  end for  */
  432. }  /* End schleife()  */
  433.  
  434. do_gadget_text (mes, win)       /* execute text-gadget */
  435. struct IntuiMessage *mes;
  436. struct Window *win;
  437. {
  438.   struct Gadget *igad;
  439.   int gadgid;
  440.  
  441.   igad = (struct Gadget *) mes->IAddress;
  442.   gadgid = igad->GadgetID;
  443.     switch(gadgid)
  444.      {                              
  445.     case 1: suchen(DefString); break;
  446.      };
  447. }
  448.  
  449. do_gadgets_bool (mes, win)       /* execute BOOL-gadgets */
  450. struct IntuiMessage *mes;
  451. struct Window *win;
  452. {
  453.   struct Gadget *igad;
  454.   int gadgid;
  455.  
  456.   igad = (struct Gadget *) mes->IAddress;
  457.   gadgid = igad->GadgetID;
  458.     switch(gadgid)
  459.      {                              
  460.     case 2: drucke(DefString); break;
  461.     case 3: ende(0);
  462.     case 4: list(); break;
  463.     case 5: input(0); break;  /* = new input */
  464.     case 7: if((anderung==TRUE)&&(zaehler>0)) /*load*/
  465.         {movemouse(190,38);
  466.         ergebnis = AutoRequest(NULL,&text5,&postext1,&negtext1,NULL,NULL,260,50);
  467.           if(ergebnis==TRUE) offne_file(1); 
  468.             /* if file has been saved: Request: Save ? */
  469.         }
  470.         offne_file(0); break;
  471.     case 6: if(zaehler==0)
  472.          {movemouse(150,33);
  473.           ergebnis = AutoRequest(NULL,&text,&postext1,&postext1,NULL,NULL,200,50);
  474.           movemouse(w->LeftEdge+150,w->TopEdge+130); break;}
  475.         offne_file(1); break; /*save*/
  476.     case 8: input(1); break;      /* = edit record */
  477.     case 9: neu(); break;
  478.     case 10: del(); break;
  479.      };
  480. }
  481.  
  482.  
  483. /*
  484.  *    the functions
  485.  */
  486.  
  487. status(was)  /* shows status */
  488. char *was;
  489. {
  490. Move(rp,16,25); Text(rp,was,25);
  491. }
  492.  
  493. s()
  494. {status("Click gadget ...         ");}
  495.  
  496. de()
  497. {Delay(50L); s();}
  498.  
  499. schein_request(an)  /* Requester: mouse-clicks won't be buffered ! */
  500. int an;   /* 1 = onn, 0 = off */
  501. {
  502. if(an==1)
  503.  {InitRequester(&request);
  504.   Request(&request,w);}
  505. else
  506.  EndRequest(&request,w);
  507. }
  508.  
  509. draw()    /* Opening the main-window */
  510. {
  511.  if(!(w = (struct Window *)OpenWindow(&nw))) ende(5);
  512.  
  513.     rp = w->RPort;
  514. SetRast(rp,2);
  515.  
  516. SetAPen(rp,2);SetBPen(rp,1);Move(rp,16,12); Text(rp,"Status:",7);
  517.  
  518.  SetAPen(rp,0);
  519.     RectFill(rp,12,140,110,151);     /* blue background at CANCEL-gadget */
  520.  
  521. SetAPen(rp,3);SetBPen(rp,1);
  522. Move(rp,16,68); Text(rp," Number of records: ",20);
  523. Move(rp,16,85); Text(rp,"  Name:",7);
  524. Move(rp,16,95); Text(rp,"Street:",7);
  525. Move(rp,16,105);Text(rp,"  Town:",7);
  526. Move(rp,16,115);Text(rp," Phone:",7);
  527.  
  528.  
  529.  SetAPen(rp,1);SetBPen(rp,2);
  530. DrawBorder(rp,&StrBorder,0,0);
  531. RefreshGadgets(&tex_gad,w,NULL);     /* draw gadgets */  
  532. print_anzahl();
  533. }
  534.  
  535. drucke(wen)    /* print address */
  536. char *wen;
  537. {
  538. char john[30];
  539. UBYTE *reg2 = 12570624;
  540. UBYTE a;
  541. a = *reg2&1; 
  542.  
  543. if(zaehler==0)   {movemouse(150,33);
  544.           ergebnis = AutoRequest(NULL,&text,&postext1,&postext1,NULL,NULL,200,50);
  545.           goto close_it;}
  546.  
  547. for(i=0;i<zaehler;i++)
  548. { if( my_strcmp(wen,person[i]->such_begriff)==NULL)
  549.     {
  550.     strcpy(john," Print <");
  551.     strcat(john,person[i]->such_begriff);
  552.     strcat(john,"> ? ");
  553.     (UBYTE *) text2.IText = (UBYTE *)john;
  554.         movemouse((strlen(john)*10)-50,38);
  555.     ergebnis = AutoRequest(NULL,&text2,&postext1,&negtext1,NULL,NULL,strlen(john)*10+5,50);
  556.      if(ergebnis == FALSE) goto close_it;
  557.  
  558.     if(a==1) {status("Printer  off_line !      "); de(); goto close_it; }
  559.     if((faus=fopen("par:","w"))==NULL)
  560.               {status("No parallel.device !     "); de(); return(0);}
  561.     status("Printing address.        ");
  562.     fputs(person[i]->name,faus);
  563.       fputs("\n",faus);
  564.     fputs(person[i]->strasse,faus);
  565.       fputs("\n",faus);
  566.     fputs(person[i]->ort,faus);
  567.       fputs("\n",faus);
  568.     fputs(person[i]->tel,faus);
  569.       fputs("\n\n",faus);
  570.      if(faus) fclose(faus);
  571.       s();
  572.      return(1);
  573.     }
  574. }
  575.  
  576.     movemouse(150,33);
  577. ergebnis = AutoRequest(NULL,&text3,&postext1,&postext1,NULL,NULL,200,50);
  578.  
  579. close_it: movemouse(w->LeftEdge+150,w->TopEdge+130); return(0);
  580.  
  581. }  /*  end drucke() */
  582.  
  583.  
  584. open_file(welches)    /* read data-file into memory */
  585. UBYTE welches[30];
  586. {
  587. register char *z, *hilf;
  588. long number;
  589.  
  590. status("Opening File !           ");     
  591. if((eintrag = AllocMem(sizeof(struct FileInfoBlock),0L))==NULL) ende(6);
  592. if(( lock = (struct FileLock *) Lock(welches,ACCESS_READ))==NULL) 
  593.     {kein_wofile(); return(0);}
  594. if(Examine(lock,eintrag)==NULL)
  595.     {kein_wofile(); return(0);}
  596.  UnLock(lock);
  597.  
  598. if((platz = AllocMem(eintrag->fib_Size,0L))==NULL) 
  599.     {kein_wofile(); ende(6);}
  600. if((fein=Open(welches,MODE_OLDFILE))==NULL)
  601.     {kein_wofile(); return(0);}
  602.  
  603. number = Read(fein,platz,eintrag->fib_Size);
  604. if(fein) Close(fein);
  605.  
  606. get_sesam();
  607. if(DefString4[0]!=0) {compute(DefString4); 
  608.               decodiere(platz,number);
  609.               strcpy(DefString4,"\0"); } 
  610.  
  611. SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  612.  
  613.   strcpy(DefString,"\0"); 
  614. RefreshGadgets(&tex_gad,w,NULL);
  615.  
  616. if(zaehler>0)
  617.     { for(i=0;i<zaehler;i++)
  618.          { if(person[i]) FreeMem(person[i],sizeof(struct Daten));
  619.            person[i] = 0; 
  620.          }
  621.     }
  622. for(i=0;i<MAXI;i++) person[i] = 0;
  623. zaehler = 0;
  624.  
  625. /*  scan and modify in memory  */
  626.  
  627. z = platz;   /* = begin of data in memory */
  628.  
  629. if(*z!='{')  mach_reset();
  630.  
  631. for(;;)
  632. {
  633. for(;*z!='~' && *z!='{';z++) ;
  634. if(*z=='~') break;        /* end of list -> break */
  635.  
  636. if((person[zaehler] = AllocMem(sizeof(struct Daten),0L))==NULL) break;
  637. z+=1;
  638. hilf = z;
  639. for(;*z!='[';z++) ;
  640.   *(z-1) = '\0';
  641. strcpy(person[zaehler]->such_begriff,hilf);
  642. z+=1;
  643. hilf = z;
  644. for(;*z!='[';z++) ;
  645.   *(z-1) = '\0';
  646. strcpy(person[zaehler]->name,hilf);
  647. z+=1;
  648. hilf = z;
  649. for(;*z!='[';z++) ;
  650.   *(z-1) = '\0';
  651. strcpy(person[zaehler]->strasse,hilf);
  652. z+=1;
  653. hilf = z;
  654. for(;*z!='[';z++) ;
  655.   *(z-1) = '\0';
  656. strcpy(person[zaehler]->ort,hilf);
  657. z+=1;
  658. hilf = z;
  659. for(;*z!=']';z++) ;
  660.   *(z) = '\0';
  661. strcpy(person[zaehler]->tel,hilf);
  662.  
  663. zaehler += 1;
  664. }   
  665.  
  666. anderung = FALSE;
  667. if(eintrag)   FreeMem(eintrag,sizeof(struct FileInfoBlock));
  668. if(platz)     FreeMem(platz,eintrag->fib_Size);
  669.  
  670. print_anzahl();
  671.  
  672.   RefreshGadgets(&tex_gad,w,NULL);
  673.  
  674.  s();
  675. }  /* End open_file()  */
  676.  
  677. kein_wofile()    /* error during read-in data into memory */
  678. {
  679. if(lock) {UnLock(lock); lock = NULL;}
  680. if(platz)   {FreeMem(platz,eintrag->fib_Size); platz = NULL;}
  681. if(eintrag) {FreeMem(eintrag,sizeof(struct FileInfoBlock)); eintrag=NULL;}
  682. status("File - Error !           "); Delay(50L);
  683. status("Load - Mode ...          ");
  684. }
  685.  
  686. mach_reset()    /* wrong password: Good By ! */
  687. {
  688. SetTaskPri(FindTask(0),127);
  689. DisplayAlert(RECOVERY_ALERT,&alert1[0],50);
  690. Forbid(); Disable();
  691. sys_info(3,"Reset your system !!!",200);
  692.  reset();
  693. }
  694.  
  695. reset()     /* wrong password: reset ! */
  696. {
  697. #asm
  698.     move $0,34
  699. #endasm
  700. }
  701.  
  702. my_strcmp(t1,t2)
  703. char *t1,*t2;
  704. {
  705. register unsigned char c1, c2;
  706. register COUNT count;
  707. for(count=0; count<=strlen(t1); count++)
  708.  {
  709.   c1=t1[count];
  710.   c2=t2[count];
  711.       if(c1>180) c1=c1-131;
  712.       if(c2>180) c2=c2-131;
  713.   if(c2>=65 && c2<=90) c2 +=32;
  714.   if(c1>=65 && c1<=90) c1 +=32;
  715.   if(c1<c2) return(-1);
  716.   if(c1>c2) return(1);
  717.  }
  718.  return(0);
  719. }
  720.  
  721. suchen(wen)    /* searches for term and and gives you suitable address */
  722. char *wen;
  723. {
  724. for(i=0;i<zaehler;i++)
  725. { if( my_strcmp(wen,person[i]->such_begriff)==NULL)
  726.     { SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  727.  
  728.       Move(rp,80,85);  Text(rp,person[i]->name,strlen(person[i]->name));
  729.       Move(rp,80,95);  Text(rp,person[i]->strasse,strlen(person[i]->strasse));
  730.       Move(rp,80,105); Text(rp,person[i]->ort,strlen(person[i]->ort));
  731.       Move(rp,80,115); Text(rp,person[i]->tel,strlen(person[i]->tel));
  732.       return(1);}
  733. }
  734.   status("No matching record !     "); de(); return(0);
  735. }  /* end suchen()  */
  736.  
  737. start_timer()    /* initializing of timer-clock */
  738. {
  739. timereq.tr_time.tv_secs = 0;
  740. timereq.tr_time.tv_micro = 999500;
  741. timereq.tr_node.io_Command = TR_ADDREQUEST;
  742. timereq.tr_node.io_Flags = 0;
  743. timereq.tr_node.io_Error = 0;
  744. timereq.tr_node.io_Message.mn_ReplyPort = timerport;
  745.  
  746. SendIO((char *) &timereq.tr_node);
  747. }
  748.  
  749. print_time(diff)    /* prints time on screen */
  750. long diff;
  751. {
  752. char s[8];
  753. long h,m;
  754. h=diff/3600;
  755. diff -=h*3600;
  756. m=diff/60;
  757. diff -=m*60;
  758.  
  759. if(h<10)
  760.   {s[0] = '0'; s[1] = '0'+h;}
  761.  else {s[0] = '0'+(h/10); s[1] = '0'+(h-((h/10)*10));}
  762.  
  763. s[2] = ':';
  764.  
  765. if(m<10)
  766.   {s[3] = '0'; s[4] = '0'+m;}
  767.  else {s[3] = '0'+(m/10); s[4] = '0'+(m-((m/10)*10));}
  768.  
  769. s[5] = ':';
  770.  
  771. if(diff<10)
  772.   {s[6] = '0'; s[7] = '0'+diff;}
  773.  else {s[6] = '0'+(diff/10); s[7] = '0'+(diff-((diff/10)*10));}
  774.  
  775. s[8] = '\0';
  776.  
  777.  Move(rp,210,12);
  778.  Text(rp,&s,8L);
  779. }
  780.  
  781. offne_file(knoff)    /* load/save a file */
  782. short knoff;
  783. {
  784. struct RastPort *rp_name;
  785. struct IntuiMessage *message2;
  786. ULONG class2; USHORT code2;
  787.   struct Gadget *igad2;
  788.   int gadgid2;
  789.  
  790. schein_request(1); /*an*/
  791.  
  792. if(knoff==1) {  status("Save - Mode ...          ");
  793.         nw3.Title = (UBYTE *)" File-Name  (Save)";
  794.         yes_str.IText = (UBYTE *)"  Save";}
  795. if(knoff==0) {  status("Load - Mode ...          ");
  796.         nw3.Title = (UBYTE *)" File-Name  (Load)";
  797.         yes_str.IText = (UBYTE *)"  Load";}
  798.  
  799. if(!(offne_win = (struct Window *)OpenWindow(&nw3))) {sys_info(3,"No  List-WINDOW !",0); return(0);}
  800.    rp_name = offne_win->RPort;
  801. SetRast(rp_name,2);
  802. SetAPen(rp_name,0);
  803.     movemouse(a_w->LeftEdge+230,a_w->TopEdge+42);
  804.  
  805. RectFill(rp_name,20,27,119,38);
  806. RectFill(rp_name,140,27,239,38);
  807. RefreshGadgets(&file_gad,offne_win,NULL);
  808. DrawBorder(rp_name,&StrBorder3,0,0);
  809. ActivateGadget(&file_gad,offne_win,NULL);
  810.  
  811. for(;;)
  812. {
  813. Wait(1<<offne_win->UserPort->mp_SigBit);
  814.     while(message2 = (struct IntuiMessage *)GetMsg(offne_win->UserPort))
  815.     {
  816.      class2 = message2->Class;
  817.      code2 = message2->Code;
  818.      ReplyMsg(message2);
  819.       igad2 = (struct Gadget *) message2->IAddress;
  820.       gadgid2 = igad2->GadgetID;
  821.      switch (class2)
  822.       {
  823.        case GADGETDOWN:
  824.         switch(gadgid2)
  825.          {                              
  826.         case 2: if(knoff==0) {if(open_file(DefString2)!=0) goto sense; }   /*yes */
  827.             if(knoff==1) {if(speichern(DefString2)!=0) goto sense; }
  828.             ActivateGadget(&file_gad,offne_win,NULL); break;
  829.         case 3: goto sense; break;    /* no */
  830.          };
  831.        case GADGETUP: 
  832.         switch(gadgid2)
  833.           {case 1:    if(knoff==0) {if(open_file(DefString2)!=0) goto sense; }   /*yes */
  834.             if(knoff==1) {if(speichern(DefString2)!=0) goto sense; }
  835.             ActivateGadget(&file_gad,offne_win,NULL); break;
  836.          };
  837.       };
  838.     } /*  end while  */
  839. }   /*  end for  */
  840.  
  841. sense:
  842. schein_request(0); /*off*/
  843. if(offne_win)  {CloseWindow(offne_win); offne_win=NULL;
  844. s();
  845. movemouse(w->LeftEdge+150,w->TopEdge+130);
  846. }
  847. }   /*  End offne_file()  */
  848.  
  849. int vergleich(a,b)    /* for quicksort()  */
  850. char *a, *b;
  851. {
  852. return(my_strcmp(a,b));
  853. }
  854.  
  855. list()    /* shows you list of terms (alphabetical), click them ! */
  856. {
  857. struct RastPort *rp_list;
  858. struct IntuiMessage *message2;
  859. ULONG class2; USHORT code2;
  860.   struct Gadget *igad2;
  861.   int gadgid2;
  862. register int j=0, akt=0;
  863.  
  864. schein_request(1); /*an*/
  865. status("List - Mode ...          ");
  866.  
  867. for(i=0;i<MAXI;i++) strcpy(liste[i],"\0");
  868.  
  869. if(zaehler==0)   {movemouse(150,33);
  870.           ergebnis = AutoRequest(NULL,&text,&postext1,&postext1,NULL,NULL,200,50);
  871.           goto close_it_2;}
  872.  
  873.  if(!(list_win = (struct Window *)OpenWindow(&nw4))) {sys_info(3,"No  List-WINDOW !",0); return(0);}
  874.     rp_list = list_win->RPort;
  875.       SetRast(rp_list,2);
  876.       SetAPen(rp_list,3); SetBPen(rp_list,1); SetDrMd(rp_list,JAM2);
  877.     movemouse(a_w->LeftEdge+30,a_w->TopEdge+187);
  878.  
  879. for(i=0;i<zaehler;i++)
  880.          strcpy(liste[i],person[i]->such_begriff);
  881.  
  882. qsort(liste,zaehler,33,vergleich);
  883.  
  884.      j = ((zaehler-1)/13);  /* how many whole pages ? (13 records/page possible) */
  885.  
  886. if(zaehler<=13)
  887.      {   for(i=0;i<zaehler;i++)  (char *)namen_str[i].IText = liste[i];
  888.          Move(rp_list,6,156); Text(rp_list,"(end) ",6);
  889.          for(i=12;i>=zaehler;i--) namen_gad[i].Flags |= GADGDISABLED;
  890.      }
  891.    else  {for(i=0;i<13;i++) (char *)namen_str[i].IText = liste[i];
  892.       OnGadget(&vor_gad,list_win,NULL); akt=0;
  893.       Move(rp_list,6,156); Text(rp_list,"(more)",6);}
  894.  
  895. col(akt,-2);
  896. sprintf(Date_Buffer,"%d/%d",akt+1,j+1); Move(rp_list,a_w->Width-14-(strlen(Date_Buffer)*7),156); Text(rp_list,Date_Buffer,strlen(Date_Buffer));
  897.  
  898. for(;;)
  899. {
  900. Wait(1<<list_win->UserPort->mp_SigBit);
  901.   while(message2 = (struct IntuiMessage *)GetMsg(list_win->UserPort))
  902.     {
  903.       class2 = message2->Class;
  904.       code2  = message2->Code;     
  905.       ReplyMsg(message2);
  906.       igad2 = (struct Gadget *) message2->IAddress;
  907.       gadgid2 = igad2->GadgetID;
  908.       switch (class2)
  909.        {
  910.     case MOUSEBUTTONS: if(code2==MENUDOWN) goto close_it_1; break; 
  911.     case CLOSEWINDOW: goto close_it_1;
  912.     case GADGETDOWN:
  913.         if(gadgid2>=0 && gadgid2<=12) {such(gadgid2);col(akt,gadgid2);} break;
  914.         case GADGETUP:
  915.         if(gadgid2>=0 && gadgid2<=12) {RefreshGadgets(&namen_gad[12],list_win,NULL);}
  916.         if(gadgid2==20) /*go on*/
  917.               {akt = akt+1; 
  918.               for(i=0;i<13;i++) (char *)namen_str[i].IText = liste[(akt*13)+i];
  919.                  SetRast(rp_list,2);
  920.               OnGadget(&zurueck_gad,list_win,NULL);
  921.               if(akt==j) { for(i=12;i>=zaehler-(j*13);i--) namen_gad[i].Flags |= GADGDISABLED; 
  922.                        vor_gad.Flags |= GADGDISABLED; 
  923.                        Move(rp_list,6,156); Text(rp_list,"(end) ",6);}
  924.                  else {Move(rp_list,6,156); Text(rp_list,"(more)",6);} 
  925.              sprintf(Date_Buffer,"%d/%d",akt+1,j+1); Move(rp_list,a_w->Width-14-(strlen(Date_Buffer)*7),156); Text(rp_list,Date_Buffer,strlen(Date_Buffer));
  926.               col(akt,-1);
  927.              }
  928.         if(gadgid2==21) /*go back*/
  929.              {   for(i=12;i>=zaehler-(j*13);i--) namen_gad[i].Flags &= ~GADGDISABLED; 
  930.               akt = akt-1; 
  931.              for(i=0;i<13;i++) (char *)namen_str[i].IText = liste[(akt*13)+i];
  932.                 SetRast(rp_list,2);
  933.              OnGadget(&vor_gad,list_win,NULL);
  934.                   Move(rp_list,6,156); Text(rp_list,"(more)",6);
  935.              if(akt==0) zurueck_gad.Flags |= GADGDISABLED;
  936.             sprintf(Date_Buffer,"%d/%d",akt+1,j+1); Move(rp_list,a_w->Width-14-(strlen(Date_Buffer)*7),156); Text(rp_list,Date_Buffer,strlen(Date_Buffer));
  937.              col(akt,-1);
  938.              }
  939.        };/* switch class2 */
  940.       } /*  end while  */
  941.  }   /*  end for  */
  942.  
  943. close_it_1:
  944. for(i=12;i>=zaehler-(j*13);i--) namen_gad[i].Flags &= ~GADGDISABLED; 
  945. zurueck_gad.Flags |= GADGDISABLED; 
  946. vor_gad.Flags |= GADGDISABLED;
  947. if(list_win) {CloseWindow(list_win); list_win=NULL;}
  948.  
  949. close_it_2: 
  950. schein_request(0); /*aus*/
  951. s();
  952. movemouse(w->LeftEdge+150,w->TopEdge+130);
  953. } /* end list()  */
  954.  
  955. such(a)
  956. short a;
  957. {
  958. strcpy(DefString,(char *)namen_str[a].IText);
  959.     RefreshGadgets(&tex_gad,w,NULL);
  960. suchen((char *)namen_str[a].IText);
  961. }
  962.  
  963. col(page,num)    /* changes color of activated tracing term */
  964. short page;
  965. short num;
  966. {
  967. static short st_page=-1;
  968. static short st_num=-1;
  969. short i;
  970.  
  971. if(num==-2)
  972.   { for(i=0;i<=12;i++) {namen_str[i].FrontPen=1; namen_str[i].BackPen=2;}
  973.     st_page=-1; st_num=-1; }
  974. if(num==-1)
  975.   { if(st_page==page) {namen_str[st_num].FrontPen=2; namen_str[st_num].BackPen=1;}
  976.     else for(i=0;i<=12;i++) {namen_str[i].FrontPen=1; namen_str[i].BackPen=2;} }
  977. if(num<0) RefreshGadgets(&namen_gad[12],list_win,NULL);
  978.  
  979. if(num>=0)
  980.   { st_page=page; st_num=num;
  981.     for(i=0;i<=12;i++) {namen_str[i].FrontPen=1; namen_str[i].BackPen=2;}
  982.     namen_str[st_num].FrontPen=2; namen_str[st_num].BackPen=1; }
  983. } /* end col() */
  984.  
  985. input(edit)    /* new input (edit=0), modify record (edit=1) */ 
  986. short edit;
  987. {
  988. struct RastPort *rp_input;
  989. struct IntuiMessage *message2;
  990. ULONG class2; USHORT code2;
  991.   struct Gadget *igad2;
  992.   int gadgid2;
  993. short what = 1;
  994.  
  995. schein_request(1); /*an*/
  996.  
  997. if(edit==1)
  998. {
  999. status("Edit - Mode ...          ");
  1000.  for(i=0;i<zaehler;i++) 
  1001.     if( my_strcmp(DefString,person[i]->such_begriff)==NULL) 
  1002.         {strcpy(DefString3,person[i]->such_begriff); 
  1003.         nw5.Title = (UBYTE *)" Edit "; goto weiter;}
  1004.     movemouse(150,33);
  1005.      ergebnis = AutoRequest(NULL,&text3,&postext1,&postext1,NULL,NULL,200,50);
  1006.      goto close_in;
  1007. }
  1008.  
  1009. if(edit==0) {nw5.Title = (UBYTE *)" Input ";
  1010.          status("Input - Mode ...         ");}
  1011. weiter:
  1012.  if(!(input_win = (struct Window *)OpenWindow(&nw5))) { sys_info(3,"No Input/Edit-WINDOW !",0); return(0);}
  1013.     rp_input = input_win->RPort;
  1014.  
  1015.     SetRast(rp_input,2); movemouse(a_w->LeftEdge+10,a_w->TopEdge+5);
  1016.  
  1017.     DrawBorder(rp_input,&StrBorder4,0,0);
  1018.     SetAPen(rp_input,1); SetBPen(rp_input,2); SetDrMd(rp_input,JAM2);
  1019.     Move(rp_input,5,10); Text(rp_input,"Tracing term:   ",16);
  1020.  
  1021. if(edit==0) {strcpy(DefString,"\0"); RefreshGadgets(&tex_gad,w,NULL);
  1022.         strcpy(DefString3,"\0");
  1023.         SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);}
  1024.  
  1025.  
  1026. for(;;)
  1027. {
  1028. RefreshGadgets(&input_tex_gad,input_win,NULL);
  1029. ActivateGadget(&input_tex_gad,input_win,NULL);
  1030.  
  1031. Wait(1<<input_win->UserPort->mp_SigBit);
  1032.  
  1033.   while(message2 = (struct IntuiMessage *)GetMsg(input_win->UserPort))
  1034.     {
  1035.       class2 = message2->Class;
  1036.       code2  = message2->Code;     
  1037.       ReplyMsg(message2);
  1038.       igad2 = (struct Gadget *) message2->IAddress;
  1039.       gadgid2 = igad2->GadgetID;
  1040.       switch (class2)
  1041.        {
  1042.     case CLOSEWINDOW: goto close_in;
  1043.         case GADGETDOWN:
  1044.         switch(gadgid2)
  1045.          {case 1: break;                              
  1046.          };
  1047.         case GADGETUP:
  1048.         switch(gadgid2)
  1049.          {                              
  1050. case 1:
  1051.  
  1052. if(what==1)
  1053. {
  1054.  
  1055.  if(edit==0)
  1056.  {if((person[zaehler] = AllocMem(sizeof(struct Daten),0L))==NULL) return(0);
  1057.   strcpy(person[zaehler]->such_begriff,DefString3);
  1058.   strcpy(DefString,DefString3); 
  1059.   strcpy(DefString3,"\0"); 
  1060.  }
  1061.  
  1062.  if(edit==1)
  1063.  {
  1064.   strcpy(person[i]->such_begriff,DefString3);
  1065.   strcpy(DefString,DefString3); 
  1066.   strcpy(DefString3,person[i]->name);
  1067.  }
  1068.  
  1069.  RefreshGadgets(&tex_gad,w,NULL);
  1070. Move(rp_input,5,10); Text(rp_input,"Name/First-Name:",16);
  1071. what = 2;
  1072. break;
  1073. }
  1074.  
  1075. if(what==2)
  1076. {
  1077. Move(rp,80,85);  Text(rp,DefString3,strlen(DefString3));
  1078.  
  1079. if(edit==0) {strcpy(person[zaehler]->name,DefString3); strcpy(DefString3,"\0");} 
  1080.  
  1081. if(edit==1) 
  1082. {strcpy(person[i]->name,DefString3); strcpy(DefString3,person[i]->strasse);
  1083.  suchen((char *)DefString);}
  1084.  
  1085.     Move(rp_input,5,10); Text(rp_input,"Street:         ",16);
  1086.  
  1087. what = 3;
  1088. break;
  1089. }
  1090.  
  1091. if(what==3)
  1092. {
  1093. Move(rp,80,95);  Text(rp,DefString3,strlen(DefString3));
  1094.  
  1095. if(edit==0) {strcpy(person[zaehler]->strasse,DefString3); strcpy(DefString3,"\0");}
  1096. if(edit==1) 
  1097. {strcpy(person[i]->strasse,DefString3); strcpy(DefString3,person[i]->ort);
  1098.  suchen((char *)DefString);}
  1099.  
  1100.  
  1101.     Move(rp_input,5,10); Text(rp_input,"Town:           ",16);
  1102.  
  1103. what = 4;
  1104. break;
  1105. }
  1106.  
  1107. if(what==4)
  1108. {
  1109. Move(rp,80,105);  Text(rp,DefString3,strlen(DefString3));
  1110.  
  1111. if(edit==0) {strcpy(person[zaehler]->ort,DefString3); strcpy(DefString3,"\0");}
  1112. if(edit==1) 
  1113. {strcpy(person[i]->ort,DefString3); strcpy(DefString3,person[i]->tel);
  1114.  suchen((char *)DefString);}
  1115.  
  1116.     Move(rp_input,5,10); Text(rp_input,"Phone-Nr.:      ",16);
  1117.  
  1118. what = 5;
  1119. break;
  1120. }
  1121.  
  1122. if(what==5)
  1123. {
  1124. Move(rp,80,115);  Text(rp,DefString3,strlen(DefString3));
  1125.  
  1126. if(edit==0) {strcpy(person[zaehler]->tel,DefString3);
  1127.              strcpy(DefString3,"\0");
  1128.         Move(rp_input,5,10); Text(rp_input,"Tracing term:",13);
  1129.     SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  1130.        strcpy(DefString,"\0"); 
  1131.     RefreshGadgets(&tex_gad,w,NULL);
  1132.     zaehler +=1;
  1133.     print_anzahl();
  1134.     what = 1; }
  1135. if(edit==1) {strcpy(person[i]->tel,DefString3);
  1136.          suchen((char *)DefString);
  1137.          goto close_in;}
  1138. break;
  1139. }
  1140.          };/*switch gadgid*/ break;
  1141.  
  1142.        };/*switch messageclass*/
  1143.       } /*  end while  */
  1144.  }   /*  end for  */
  1145.  
  1146. close_in:
  1147. anderung = TRUE;
  1148. if(input_win) {CloseWindow(input_win); input_win=NULL;} 
  1149. if(edit==0){SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  1150.         strcpy(DefString,"\0"); 
  1151.         RefreshGadgets(&tex_gad,w,NULL);}
  1152. schein_request(0); /*aus*/
  1153. s();
  1154.   movemouse(w->LeftEdge+150,w->TopEdge+130);
  1155. } /* end input()  */
  1156.  
  1157.  
  1158. speichern(speicher_string)    /* the saving */
  1159. UBYTE speicher_string[30];
  1160. {
  1161. char *hilf;
  1162. LONG anzahl = 0;
  1163. int handle;
  1164.  
  1165. status("Saving file ...          ");
  1166.  
  1167. if((handle=creat(speicher_string,0))==-1)
  1168.     {status("Saving-Error !!!         "); de(); return(0);}
  1169.  
  1170. for(i=0;i<zaehler;i++)
  1171. {
  1172. anzahl = anzahl + strlen(person[i]->such_begriff)
  1173.         + strlen(person[i]->name)
  1174.         + strlen(person[i]->strasse)
  1175.         + strlen(person[i]->ort)
  1176.         + strlen(person[i]->tel)
  1177.         + 10;   /* die Klammern */
  1178. }
  1179. anzahl += 2;   /* for ~ und \0 */
  1180.  
  1181. if((platz = AllocMem(anzahl,0L))==NULL) 
  1182.    {status("Saving-Error !!!         "); de(); return(0);}
  1183.  
  1184. hilf = platz;
  1185.  
  1186. for(i=0;i<zaehler;i++)
  1187. {
  1188. strcpy(hilf,"{");
  1189.  hilf+=1;
  1190.  
  1191. strcat(hilf,person[i]->such_begriff);
  1192.   hilf+=strlen(person[i]->such_begriff);
  1193.  strcat(hilf,"}[");
  1194.   hilf+=2;
  1195.  
  1196. strcat(hilf,person[i]->name);
  1197.  hilf+=strlen(person[i]->name);
  1198.  strcat(hilf,"][");
  1199.   hilf+=2;
  1200.  
  1201. strcat(hilf,person[i]->strasse);
  1202.  hilf+=strlen(person[i]->strasse);
  1203.  strcat(hilf,"][");
  1204.   hilf+=2;
  1205.  
  1206. strcat(hilf,person[i]->ort);
  1207.  hilf+=strlen(person[i]->ort);
  1208.  strcat(hilf,"][");
  1209.   hilf+=2;
  1210.  
  1211. strcat(hilf,person[i]->tel);
  1212.  hilf+=strlen(person[i]->tel);
  1213.  strcat(hilf,"]");
  1214.   hilf+=1;
  1215. }
  1216.  
  1217. strcat(hilf,"~\0");
  1218.  
  1219. get_sesam();
  1220. if(DefString4[0]!=0) {compute(DefString4); 
  1221.                       codiere(platz,anzahl);
  1222.               strcpy(DefString4,"\0"); } 
  1223.  
  1224. write(handle,platz,anzahl);
  1225. close(handle);
  1226. if(platz)     FreeMem(platz,anzahl);
  1227.  
  1228. anderung = FALSE; movemouse(w->LeftEdge+150,w->TopEdge+130);
  1229.  
  1230. DisplayBeep(NULL);
  1231. s();
  1232. return(1);
  1233. }  /* end speichern()  */
  1234.  
  1235.  
  1236. neu()    /* delete all records */
  1237. {
  1238.  
  1239. if(zaehler==0) goto aff;
  1240.  
  1241.     movemouse(150,33);
  1242. ergebnis = AutoRequest(NULL,&text4,&postext1,&negtext1,NULL,NULL,200,50);
  1243.     if(ergebnis==FALSE) goto aff;
  1244.  
  1245.  for(i=0;i<zaehler;i++)
  1246.          { if(person[i]) FreeMem(person[i],sizeof(struct Daten));
  1247.            person[i] = 0; 
  1248.          }
  1249. for(i=0;i<MAXI;i++) person[i] = 0;
  1250. zaehler = 0;
  1251. print_anzahl();
  1252. strcpy(DefString,"\0"); RefreshGadgets(&tex_gad,w,NULL);
  1253. SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  1254. anderung = TRUE;
  1255.  
  1256. aff: movemouse(w->LeftEdge+150,w->TopEdge+130);
  1257. }  /*  end neu() */
  1258.  
  1259.  
  1260. del()    /* delete actual record */
  1261. {
  1262. char john[30];
  1263. short a;
  1264.  
  1265. if(zaehler==0)   {movemouse(150,33);
  1266.           ergebnis = AutoRequest(NULL,&text,&postext1,&postext1,NULL,NULL,200,50);
  1267.           goto close_neu;}
  1268.  
  1269. for(i=0;i<zaehler;i++)
  1270. { if( my_strcmp(DefString,person[i]->such_begriff)==NULL)
  1271.     {
  1272.     strcpy(john," Delete <");
  1273.     strcat(john,person[i]->such_begriff);
  1274.     strcat(john,"> ? ");
  1275.     (UBYTE *) text2.IText = (UBYTE *)john;
  1276.  
  1277.         movemouse((strlen(john)*10)-50,38);
  1278.     ergebnis = AutoRequest(NULL,&text2,&postext1,&negtext1,NULL,NULL,strlen(john)*10+5,50);
  1279.         movemouse(w->LeftEdge+150,w->TopEdge+130);
  1280.       if(ergebnis == FALSE) goto close_neu;
  1281.  
  1282.  
  1283.     if(person[i]) FreeMem(person[i],sizeof(struct Daten));
  1284.     for(a=i;a<zaehler;a++) person[a] = person[a+1];
  1285.     zaehler -=1; person[zaehler] = 0; /* last record = 0 */
  1286.  
  1287.     print_anzahl();
  1288.     strcpy(DefString,"\0"); RefreshGadgets(&tex_gad,w,NULL);
  1289.     SetAPen(rp,2); RectFill(rp,77,78,285,120); SetAPen(rp,1);
  1290.  
  1291.         status("Record deleted.           "); de();
  1292.     anderung = TRUE; return(1);
  1293.     }
  1294. }
  1295.  
  1296.     movemouse(130,33);
  1297. ergebnis = AutoRequest(NULL,&text3,&postext1,&postext1,NULL,NULL,200,50);
  1298.  
  1299. close_neu: 
  1300. movemouse(w->LeftEdge+150,w->TopEdge+130);
  1301. return(0);
  1302. }  /*  end del() */
  1303.  
  1304. movemouse (ziel_x, ziel_y)    /* moves mouse-cursor to a given position; */
  1305. int ziel_x;            /* needs preferences (look at main() */
  1306. int ziel_y;
  1307. {
  1308. struct InputEvent    mouse;
  1309. struct IOStdReq *ioreq;
  1310. struct MsgPort *ioport;
  1311.  
  1312. int pos_x = IntuitionBase->ActiveScreen->MouseX;
  1313. int pos_y = IntuitionBase->ActiveScreen->MouseY;
  1314. int dx = ziel_x - pos_x;
  1315. int dy = ziel_y - pos_y;
  1316.  
  1317. if (!(ioport = CreatePort (NULL, NULL))) goto weg;
  1318. if(!(ioreq = CreateStdIO(ioport))) goto weg;
  1319. if (OpenDevice ("input.device", 0L, ioreq, 0L)) {
  1320.         ioreq -> io_Device = 0; goto weg;}
  1321.  
  1322.     ioreq -> io_Command = IND_WRITEEVENT;
  1323.     ioreq -> io_Flags = 0;
  1324.     ioreq -> io_Length = sizeof (struct InputEvent);
  1325.     ioreq -> io_Data = (APTR) &mouse;
  1326.  
  1327.     mouse.ie_NextEvent = 0;
  1328.     mouse.ie_Class = IECLASS_RAWMOUSE;
  1329.     mouse.ie_TimeStamp.tv_secs = mouse.ie_TimeStamp.tv_micro = 0;
  1330.     mouse.ie_Code = IECODE_NOBUTTON;
  1331.     mouse.ie_Qualifier = IEQUALIFIER_RELATIVEMOUSE;
  1332.     mouse.ie_X = prefs.PointerTicks * dx;
  1333.     mouse.ie_Y = prefs.PointerTicks * (dy+dy);  /* because HiRes ! */
  1334.     if(DoIO (ioreq)) goto weg;
  1335.  
  1336. weg:
  1337. if (ioreq)  {
  1338.     if(ioreq->io_Device) CloseDevice(ioreq);
  1339.     DeleteStdIO (ioreq);
  1340.         }
  1341. if (ioport) DeletePort (ioport);
  1342. } /* end movemouse() */
  1343.  
  1344.  
  1345. print_anzahl()    /* shows number of records */
  1346. {
  1347.     SetAPen(rp,2); RectFill(rp,192,60,285,72); SetAPen(rp,1);
  1348. sprintf(Date_Buffer,"%d",zaehler); Move(rp,193,68); Text(rp,Date_Buffer,strlen(Date_Buffer));
  1349. }
  1350.  
  1351. decodiere(reihe,number)
  1352. UBYTE reihe[];
  1353. LONG number;
  1354. {
  1355. ;
  1356. }  /* end decodiere()  */
  1357.  
  1358.  
  1359. codiere(reihe,number)
  1360. UBYTE reihe[];
  1361. LONG number;
  1362. {
  1363. ;
  1364. }  /* end codiere()  */
  1365.  
  1366. compute(sesam)
  1367. UBYTE sesam[];
  1368. {
  1369. ;
  1370. }  /* end compute()  */
  1371.  
  1372.  
  1373. get_sesam()    /* enter the password */
  1374. {
  1375. struct RastPort *rp_sesam;
  1376. struct IntuiMessage *message2;
  1377. ULONG class2; USHORT code2;
  1378.   struct Gadget *igad2;
  1379.   int gadgid2;
  1380.  
  1381.  if(!(sesam_win = (struct Window *)OpenWindow(&nw6))) { sys_info(3,"No Sesam-WINDOW !",0); return(0);}
  1382.     rp_sesam = sesam_win->RPort;
  1383.  
  1384.     SetRast(rp_sesam,2);
  1385.      SetAPen(rp_sesam,0);
  1386.      RectFill(rp_sesam,66,25,185,36);
  1387.  
  1388.     DrawBorder(rp_sesam,&StrBorder5,0,0);
  1389. RefreshGadgets(&sesam_gad,sesam_win,NULL); 
  1390.     ActivateGadget(&sesam_gad,sesam_win,NULL);
  1391.  
  1392. movemouse(a_w->LeftEdge+170,a_w->TopEdge+38);
  1393.  
  1394. for(;;)
  1395. {
  1396. Wait((1<<sesam_win->UserPort->mp_SigBit));
  1397.     while(message2 = (struct IntuiMessage *)GetMsg(sesam_win->UserPort))
  1398.     {
  1399.      class2 = message2->Class;
  1400.      code2 = message2->Code;
  1401.      ReplyMsg(message2);
  1402.       igad2 = (struct Gadget *) message2->IAddress;
  1403.       gadgid2 = igad2->GadgetID;
  1404.      switch (class2)
  1405.       {
  1406.     case GADGETDOWN:
  1407.         switch(gadgid2)
  1408.          {                              
  1409.         case 2: goto jesus; break; 
  1410.          };
  1411.     case GADGETUP: goto jesus; break;
  1412.       };
  1413.     } /*  end while  */
  1414. }  /* end for */
  1415.  
  1416. jesus:
  1417. if(sesam_win) {CloseWindow(sesam_win); sesam_win=NULL;}
  1418. return(1);
  1419. }
  1420.  
  1421. sys_info(a_pen,text,dauer)   /* a_pen: Color of Text; */
  1422.  int dauer;        /* if dauer==0 : then depending on the length of text */
  1423.  short a_pen;
  1424.  char *text;
  1425. {
  1426. struct Window *inf_win;
  1427. struct RastPort *inf_rp;
  1428.  
  1429.   if((new_inf_win.Width = (strlen(text)*8)+10)<190) new_inf_win.Width=190;
  1430.   new_inf_win.LeftEdge = (640-new_inf_win.Width)/2;
  1431.   new_inf_win.Title = (UBYTE *)"(Wo) User-Information: ";
  1432. if((inf_win =(struct Window *)OpenWindow(&new_inf_win)) == NULL) return(0);
  1433.   inf_rp = inf_win->RPort;
  1434.  
  1435.     SetAPen(inf_rp,1);
  1436.   RectFill(inf_rp,2,10,new_inf_win.Width-3,26);
  1437.     SetAPen(inf_rp,a_pen); SetBPen(inf_rp,1); SetDrMd(inf_rp,JAM2);
  1438.   Move(inf_rp,5,21);
  1439. Text(inf_rp,text,strlen(text));
  1440.  
  1441. switch(dauer)
  1442. {  case 0:  Delay(strlen(text)*7); break; /*von Anzahl der Buchstaben abhängig */
  1443.   default:  Delay(dauer); break;  /* so lang wie dauer */
  1444. };
  1445.  
  1446. if(inf_win) CloseWindow(inf_win);
  1447. }
  1448.  
  1449. ende(error_nr)  /* it's never to late ... */
  1450. short error_nr;
  1451. {
  1452. if((anderung==TRUE)&&(zaehler>0))
  1453. {
  1454.     movemouse(190,38);
  1455. ergebnis = AutoRequest(NULL,&text5,&postext1,&negtext1,NULL,NULL,260,50);
  1456.     if(ergebnis==TRUE) offne_file(1); 
  1457.     /* if file has been changed: save it ? */
  1458. }
  1459.  
  1460. AbortIO((char *) &timereq.tr_node);
  1461. if(openerror==0) CloseDevice(&timereq);
  1462. if(timerport) DeletePort(timerport);
  1463.  
  1464.  
  1465. if(zaehler>0)
  1466. {for(i=0;i<zaehler;i++)
  1467.  { if(person[i]) FreeMem(person[i],sizeof(struct Daten));}
  1468. }
  1469.  
  1470.   if(w) CloseWindow(w);
  1471.  
  1472. switch(error_nr)
  1473. {case 0: sys_info(2,"  User Abort.  ",0); break;
  1474.  case 1: sys_info(3,"No  DOS.library !",0); break; 
  1475.  case 2: sys_info(3,"No  GFX.library !",0); break;
  1476.  case 3: sys_info(3,"No  INTUITION.library !",0); break;
  1477.  case 4: sys_info(3,"No  TIMER-Port/Devive !",0); break;
  1478.  case 5: sys_info(3,"No  Main-WINDOW !",0); break;
  1479.  case 6: sys_info(3,"MEMORY-Allocation problem !",0); break;
  1480.  case 7: sys_info(3,"No HiRes-Screen-Resolution !",0); break;
  1481. }; 
  1482.  
  1483. if(DosBase) CloseLibrary(DosBase);
  1484.   if(GfxBase) CloseLibrary(GfxBase);
  1485.   if(IntuitionBase) CloseLibrary(IntuitionBase);
  1486.  
  1487. exit(1);
  1488. }  /* end ende()  */
  1489.